package com.mypkg.controls;

import java.util.ArrayList;

public class BasicControl {
	private String controlType;
	private ArrayList<String> attributesForControl;
	private boolean hasCloseTag;
	private String contentTag;
	
	public String getContentTag() {
		return contentTag;
	}
	public void setContentTag(String contentTag) {
		this.contentTag = contentTag;
	}
	public String getControlType() {
		return controlType;
	}
	public void setControlType(String controlType) {
		this.controlType = controlType;
	}
	public ArrayList<String> getAttributesForControl() {
		return attributesForControl;
	}
	public void setAttributesForControl(ArrayList<String> attributesForControl) {
		this.attributesForControl = attributesForControl;
	}
	public boolean isHasCloseTag() {
		return hasCloseTag;
	}
	public void setHasCloseTag(boolean hasCloseTag) {
		this.hasCloseTag = hasCloseTag;
	}
	
	public String renderFunction()
	{
		String result;
		//open tag
		result = "<"+this.controlType+" ";
		for (String s : attributesForControl)
		{
			result += s + " ";
		}
		result += ">";
		
		if (this.contentTag!=null)
		//content of tag
			result += this.contentTag;
		
		if (this.hasCloseTag)
		//close tag
			result+="</"+this.controlType+">";
		return result;
	}
}
